package lang;

/**
 * @classname:StudentTest
 * @description:
 * @author: Mr.Z
 * @date: 2020/12/7 23:07
 * @version: 0.1
 * @since:1.8
 */
public class StudentTest {
    public static void main(String[] args) {
        String[] hobby = {"code","game","music"};
        Student student = new Student(1,"jim",hobby);
        //克隆新的对象----->学生对象

        Object clone = student.clone();
        //hashcode不同
        System.out.println(student);//lang.Student@74a14482
        System.out.println(clone);//lang.Student@1540e19d
        //Student(id=1, name=jim, hobby=[code, game, music])
        //Student(id=1, name=jim, hobby=[code, game, music])


        System.out.println("-----------------------");
        //更改id值
        student.setId(2);
        System.out.println(student);
        System.out.println(clone);
        //之更改一个对象的值
        //Student(id=2, name=jim, hobby=[code, game, music])
        //Student(id=1, name=jim, hobby=[code, game, music])

        System.out.println("-----------------------");
        student.getHobby()[0] ="java code";
        //代表着clone和student都在意块内存
        System.out.println(student);
        System.out.println(clone);
        //两个对象的值都改变了
        //Student(id=2, name=jim, hobby=[java code, game, music])
        //Student(id=1, name=jim, hobby=[java code, game, music])
    }
}
